<?php
require_once '../../include/common.inc.php';
require_once '../function.php';
if(stripos(auth_group($_SESSION['login_gid']),'users_admin')===false)exit("没有权限！");
$auth_rule_userdel=false;
if(stripos(auth_group($_SESSION['login_gid']),'users_del')!==false)$auth_rule_userdel=true;

switch($act){
    case "user_del":
        if(stripos(auth_group($_SESSION['login_gid']),'users_del')===false)exit("没有权限！");
        if(is_array($id)) {
            user_del(implode(',',$id));
        } else {
            user_del($id);
        }
        //header("location:?gid=".$gid);
        header("location:" . $_SERVER['HTTP_REFERER']);
        break;
    case "ban_word":
        ban_word_add($username,$ip);
        $get_data['rid'] = 1;
        $get_data['uid'] = $uid;
        return curl_get($get_data, 'ban_word', $nodejs_url);
        break;
    case "charge_diamond":
        $a = charge($uid,$username,$total);
        $get_data['rid'] = 1;
        $get_data['uid'] = $uid;
        $get_data['cost'] = $total;
        $b =  curl_get($get_data, 'recharge', $nodejs_url);
        return $a;

        break;
}
?>
<!DOCTYPE HTML>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="../assets/css/dpl-min.css" rel="stylesheet" type="text/css" />
    <link href="../assets/css/bui-min.css" rel="stylesheet" type="text/css" />
    <link href="../assets/css/page-min.css" rel="stylesheet" type="text/css" />
    <!-- 下面的样式，仅是为了显示代码，而不应该在项目中使用-->
    <link href="../assets/css/prettify.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        code { padding: 0px 4px; color: #d14; background-color: #f7f7f9; border: 1px solid #e1e1e8; }
    </style>
    <script>
        Date.prototype.Format = function (fmt) { //author: meizz
            var o = {
                "M+": this.getMonth() + 1, //月份
                "d+": this.getDate(), //日
                "h+": this.getHours(), //小时
                "m+": this.getMinutes(), //分
                "s+": this.getSeconds(), //秒
                "q+": Math.floor((this.getMonth() + 3) / 3), //季度
                "S": this.getMilliseconds() //毫秒
            };
            if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        }
        function ftime(time){
            return new Date(time*1000).Format("yyyy-MM-dd hh:mm"); ;
        }
        function ftime2(time){
            if(time>(60*60*24)) return parseInt(time/(60*60*24))+"天";
            else if(time>(60*60))return parseInt(time/(60*60))+"小时";
            else if(time>60)return parseInt(time/60)+"分钟";
            else return parseInt(time)+"秒";
        }
        function sgid(id){
            var arr=new Array();
            if(isNaN(id)) return '';
            <?php
            $query=$db->query("select * from {$tablepre}auth_group order by id desc");
            while($row=$db->fetch_row($query)){
                echo "arr['{$row[id]}']='$row[title]';";
            }
            ?>
            return arr[id];
        }
    </script>
</head>
<body>
<div class="container"  style=" min-width:1150px;">
    <form  class="form-horizontal" action="" method="get">
        <ul class="breadcrumb">
            <li class="active">关键字：
                <input type="text" name="skey" id="rolename"class="abc input-default" placeholder="">
                <input type="hidden" name="gid" value="<?=$gid?>">
                <input type="hidden" name="fuser" value="<?=$fuser?>">
                &nbsp;&nbsp;
                <button type="submit"  class="button ">查询</button>
                <button type="button"  class="button  button-danger"  onClick="if(confirm('确定删除？'))$('#hd_list').submit()">删除所选</button>
                <?php
                if(!isset($fuser) && !isset($gid)) {
                    ?>
                    <!--                    <button type="button"  class="button  button-success"  onClick="addUser()">添加会员</button>-->
                <?php } ?>
                &nbsp;&nbsp; 用户id、用户名、操作人为查询字段</li>

        </ul>
    </form>
    <form action="" method="POST" enctype="application/x-www-form-urlencoded"  class="form-horizontal" id="hd_list">
        <input type="hidden" name="gid" value="<?=$gid?>">
        <input type="hidden" name="act" value="user_del">
        <table  class="table table-bordered table-hover definewidth m10">
            <thead>
            <tr style="font-weight:bold" >
                <td width="60" align="center" bgcolor="#FFFFFF">用户名id</td>
                <td width="19" align="center" bgcolor="#FFFFFF"><input type="checkbox" onClick="$('.ids').attr('checked',this.checked); "></td>
                <td width="80" align="center" bgcolor="#FFFFFF">用户名</td>
                <td align="80" bgcolor="#FFFFFF">充值总数</td>
                <td align="100" bgcolor="#FFFFFF">操作人</td>
                <td width="80" align="center" bgcolor="#FFFFFF">操作</td>
            </tr>
            </thead>
            <?php
            $sql="select *  from {$tablepre}gold_log   where type=2 ";
            if($skey!=""){
                $sql.=" and ( touname like '%$skey%' or touid like '%$skey%'   or uname like '%$skey%'  )";
            }

            $sql.=" order by dateline desc";


            if(!$auth_rule_userdel)$display_delbutton='style="display:none"';
            echo userlist(20,$sql,'
    <tr>
      <td bgcolor="#FFFFFF" align="center">{touid}</td>
	  <td align="center" bgcolor="#FFFFFF"><input type="checkbox" class="ids" name="id[]" value="{uid}"></td>
      <td align="center" bgcolor="#FFFFFF">{touname}</td>
      <td align="center" bgcolor="#FFFFFF">+{cost} 钻</td>
      <td align="center" bgcolor="#FFFFFF">{uname}</td>
      <td align="center" bgcolor="#FFFFFF">
      <button type="button" class="button button-mini button-danger" onclick="if(confirm(\'确定删除用户？\'))location.href=\'?act=user_del&id={uid}\'" '.$display_delbutton.'><i class="x-icon x-icon-small icon-trash icon-white"></i>删除</button></td>
    </tr>
')?>

            <!--<td align="center" bgcolor="#FFFFFF">{fuser}&nbsp;</td>-->
        </table>
    </form>
    <ul class="breadcrumb">
        <li class="active"><?=$pagenav?>
        </li>
    </ul>
</div>
<script type="text/javascript" src="../assets/js/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="../assets/js/bui.js"></script>
<script type="text/javascript" src="../assets/js/config.js"></script>
<script type="text/javascript" src="../../upload/swfupload/swfupload.js"></script>
<script>
    BUI.use('bui/overlay',function(Overlay){
        dialog = new Overlay.Dialog({
            title:'用户设置',
            width:630,
            height:600,
            buttons:[],
            bodyContent:''
        });
    });
    function openUser(id,type){
        dialog.set('bodyContent','<iframe src="user_edit.php?id='+id+'&type='+type+'" scrolling="yes" frameborder="0" height="100%" width="100%"></iframe>');
        dialog.updateContent();
        dialog.show();
    }

    function ban_word(uid,username,ip){
        var data ={
            'act':'ban_word',
            'username':username,
            'uid':uid,
            'ip':ip,
        }
        $.ajax({
            cache: true,
            type: "GET",
            url:'/admin/users/users.php',
            data:data,// 你的formid
            async: false,
            success: function(data) {
                alert('禁言成功');
            }
        });
    }

    function charge_diamond(uid,username){
        var data ={
            'act':'charge_diamond',
            'total':$('#'+uid+'charge').val(),
            'username':username,
            'uid':uid,
        }

        if(data.total <= 0 ){
            alert('设置数量必须大于零');return false;
        }

        $.ajax({
            cache: true,
            type: "GET",
            url:'/admin/users/users.php',
            data:data,// 你的formid
            async: false,
            success: function(data) {
                alert('充值成功');
            }
        });
    }

    function addUser(){
        dialog.set('bodyContent','<iframe src="user_add.php" scrolling="yes" frameborder="0" height="100%" width="100%"></iframe>');
        dialog.updateContent();
        dialog.show();
    }
</script>
</body>
</html>
